package top.soulblack.purchasesale.service.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.mapper.system.ShopMapper;
import top.soulblack.purchasesale.model.Shop;

import java.util.List;

/**
 * @Author: 廉雪峰
 * @Date: 2019/5/25 20:13
 * @Version 1.0
 */
@Service
public class ShopService {

    @Autowired
    private ShopMapper shopMapper;

    public List<Shop> selectAll() {
        return shopMapper.selectAll();
    }

    public void addShop(Shop shop) {
        shopMapper.addShop(shop);
        return;
    }

    public boolean existShop(String name) {
        int num  = shopMapper.existShop(name);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean deleteShop(int shopId) {
        int num = shopMapper.deleteByPrimaryKey(shopId);
        if (num == 1) {
            return true;
        }
        return false;
    }

    public boolean updateShop(Shop shop) {
        int num = shopMapper.updateByPrimaryKey(shop);
        if (num == 1) {
            return true;
        }
        return false;
    }
}
